/*
 * Wire
 * Copyright (C) 2018 Wire Swiss GmbH
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 */

// Custom checkbox component using Wire icon font
// Checkbox can be style using 'accent-text'
// Example:
//
//<div class="checkbox accent-text">
//  <input type="checkbox" id="checkbox" name="check"/>
//  <label for="checkbox"><div>Option</div></label>
//</div>
//
.checkbox {
  display: inline-block;
  padding-left: 2px;

  input[type='checkbox'] {
    position: absolute;
    left: var(--offscreen-left);
    opacity: 0;

    &:focus-visible + label {
      outline: 1px solid var(--accent-color);
      outline-offset: 0.4rem;
    }

    &:checked + label {
      &::after {
        opacity: 1;
      }

      &::before {
        border: 1.5px solid var(--accent-color-500);
        background-color: var(--accent-color-500);

        body.theme-dark & {
          border: 1.5px solid var(--accent-color-600);
          background-color: var(--accent-color-600);
        }
      }
    }
  }

  label {
    position: relative;
    display: inline-block;
    padding-left: 36px;
    cursor: pointer;
    line-height: 1.375rem;
    text-transform: none;
    user-select: none;
    .text-light;

    &::after,
    &::before {
      position: absolute;
      top: 0;
      left: 0;
      width: 22px;
      height: 22px;
      border-radius: 3px;
      content: '';
      transition: all 0.15s ease-in-out;
    }

    &::after {
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--white);
      content: '\e102';
      font-family: 'Wire' !important;
      font-size: var(--font-size-medium);
      line-height: 1;
      opacity: 0;
    }

    &::before {
      border: 1.5px solid var(--checkbox-border);
      background-color: var(--checkbox-background);
    }

    > div {
      color: var(--main-color) !important;
      line-height: var(--line-height-sm);
    }
  }
}
